package com.ruoyi.model.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.model.domain.ModelTaskProcess;
import com.ruoyi.model.service.IModelTaskProcessService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 任务处理Controller
 * 
 * @author rww
 * @date 2024-11-25
 */
@RestController
@RequestMapping("/model/process")
public class ModelTaskProcessController extends BaseController
{
    @Autowired
    private IModelTaskProcessService modelTaskProcessService;

    /**
     * 查询任务处理列表
     */
    @PreAuthorize("@ss.hasPermi('model:process:list')")
    @GetMapping("/list")
    public TableDataInfo list(ModelTaskProcess modelTaskProcess)
    {
        startPage();
        List<ModelTaskProcess> list = modelTaskProcessService.selectModelTaskProcessList(modelTaskProcess);
        return getDataTable(list);
    }

    /**
     * 导出任务处理列表
     */
    @PreAuthorize("@ss.hasPermi('model:process:export')")
    @Log(title = "任务处理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ModelTaskProcess modelTaskProcess)
    {
        List<ModelTaskProcess> list = modelTaskProcessService.selectModelTaskProcessList(modelTaskProcess);
        ExcelUtil<ModelTaskProcess> util = new ExcelUtil<ModelTaskProcess>(ModelTaskProcess.class);
        util.exportExcel(response, list, "任务处理数据");
    }

    /**
     * 获取任务处理详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:process:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(modelTaskProcessService.selectModelTaskProcessById(id));
    }

    /**
     * 新增任务处理
     */
    @PreAuthorize("@ss.hasPermi('model:process:add')")
    @Log(title = "任务处理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ModelTaskProcess modelTaskProcess)
    {
        return toAjax(modelTaskProcessService.insertModelTaskProcess(modelTaskProcess));
    }

    /**
     * 修改任务处理
     */
    @PreAuthorize("@ss.hasPermi('model:process:edit')")
    @Log(title = "任务处理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ModelTaskProcess modelTaskProcess)
    {
        return toAjax(modelTaskProcessService.updateModelTaskProcess(modelTaskProcess));
    }

    /**
     * 删除任务处理
     */
    @PreAuthorize("@ss.hasPermi('model:process:remove')")
    @Log(title = "任务处理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(modelTaskProcessService.deleteModelTaskProcessByIds(ids));
    }
}
